//
//  DeviceInfo.m
//  Utilities
//
//  Created by Goffredo Marocchi on 9/21/10.
//  Copyright 2010 IGGS. All rights reserved.
//

#import "DeviceInfo.h"

@interface DeviceInfo ()

-(void) updateLogic_and_RenderTimes;

@end

@implementation DeviceInfo

SYNTHESIZE_SINGLETON_FOR_CLASS(DeviceInfo)

@synthesize refreshTime, frameInterval, renderTimeMS, renderTimeSeconds, logicTimeMS, logicTimeSeconds;

-(id) init {
	if ((self=[super init])){
		frameInterval = 1;
		refreshTime = 1.0f/60.0f; //the actual value needs, for example, a CADisplayLink object to retrieve it for us.
		logicTimeSeconds = frameInterval * (refreshTime / 2.0f);
		logicTimeMS = logicTimeSeconds * 1000.0f;
		renderTimeSeconds = frameInterval * refreshTime;
		renderTimeMS = renderTimeSeconds * 1000.0f;
	}
	return self;
}

-(void) updateLogic_and_RenderTimes {	
	logicTimeSeconds = frameInterval * (refreshTime / 2.0f);
	logicTimeMS = logicTimeSeconds * 1000.0f;
	renderTimeSeconds = frameInterval * refreshTime;
	renderTimeMS = renderTimeSeconds * 1000.0f;
}

-(void) setRefreshTime:(float)time {
	refreshTime = time;
	[self updateLogic_and_RenderTimes];
}

-(void) setFrameInterval:(unsigned int)f {
	frameInterval = f;
	[self updateLogic_and_RenderTimes];
}

@end
